﻿@{
    Layout = null;
}
@model System.Collections.IEnumerable
<!DOCTYPE html>
<html>
<head>
    <title>上传下载目录树</title>
    @Html.Partial("LoadPanelPartial")
    @if (false)
    {
        <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>

    @Html.DevExpress().GetStyleSheets(

    new StyleSheet { ExtensionType = ExtensionType.ListBox, Theme = DevExpressHelper.Theme }
    )
    @Html.DevExpress().GetScripts(
        new Script { ExtensionType = ExtensionType.ListBox }
    )

    <script>
        function nodeClick(s, e) {
            parent.$("#contentframe").attr("src", e.node.name.replace("|", "&"));
        }

        function nodeInit() {

//                     var name = nodeNamecccc.GetText();
//         if (name != "") {
//             var node = LeftTreeView.GetNodeByName(name);
//             node.SetExpanded(true);
//         }
            var actionOP = $("#hdActionOP").val();
            var hdFocusNodeName = $("#hdFocusNodeName").val();
            var node = null;
            if (hdFocusNodeName == "") {
                node = LeftTreeView.GetSelectedNode();

            }
            else {
                node = LeftTreeView.GetNodeByName(hdFocusNodeName);
                LeftTreeView.SetSelectedNode(node);
            }
            if (node) {
                parent.$("#contentframe").attr("src", node.name.replace("|", "&"));
            }
        }
        function refreshNodeName(nodeName) {
            var node = LeftTreeView.GetSelectedNode();
            node.SetText(nodeName);

        }
        /*刷新节点*/
        function refreshLevelNode(focusKey) {
            if (focusKey != "") {
                parent.$("#contentleft").attr("src", rootPath + "/Admin/EnterpriseFTP/EnterpriseFTPTree?focusNodeName=" + focusKey);
            }
            else {
                parent.$("#contentleft").attr("src", rootPath + "/Admin/EnterpriseFTP/EnterpriseFTPTree");
            }
        }

        function afterDeleteNode() {
            var node = LeftTreeView.GetSelectedNode();
            var nodeIndex = node.index;
            var parentNodeCount = 0;

            if (node.parent != null) {
                parentNodeCount = node.parent.GetNodeCount();
                if (parentNodeCount == 1) {
                    node = node.parent;
                }
                else {
                    if (nodeIndex < parentNodeCount) {
                        if (nodeIndex == 0) {
                            node = node.parent.GetNode(nodeIndex + 1)
                        }
                        else {
                            node = node.parent.GetNode(nodeIndex - 1)
                        }

                    }
                }
            }
            else {
                parentNodeCount = LeftTreeView.GetNodeCount();
                if (parentNodeCount == 1) {
                    node = null;
                }
                else {

                    if (nodeIndex < parentNodeCount) {
                        if (nodeIndex == 0) {
                            node = LeftTreeView.GetNode(nodeIndex + 1)
                        }
                        else {
                            node = LeftTreeView.GetNode(nodeIndex - 1)
                        }

                    }
                }
            }
            if (node != null) {
                parent.$("#contentleft").attr("src", rootPath + "/Admin/EnterpriseFTP/EnterpriseFTPTree?focusNodeName=" + node.name);
            }
            else {
                parent.$("#contentleft").attr("src", rootPath + "/Admin/EnterpriseFTP/EnterpriseFTPTree");
                parent.$("#contentframe").attr("src", rootPath + "/Admin/EnterpriseFTP/EnterpriseFTP_NewEdit");
            }
        }

    </script>

</head>
<body>
    @Html.DevExpress().TreeView(settings =>
{
    settings.Name = "LeftTreeView";
    settings.ShowTreeLines = true;
    settings.AllowSelectNode = true;
    settings.NameField = "Id";
    settings.TextField = "Name";
    settings.EnableAnimation = false;
    settings.ClientSideEvents.NodeClick = "function(s, e) { nodeClick(s,e) }";
    settings.ClientSideEvents.Init = "function(s, e) { nodeInit(s,e) }";
    settings.PreRender = (source, e) =>
    {
        ASPxTreeView treeView = (ASPxTreeView)source;
        treeView.CollapseAll();
        if (treeView.Nodes.Count > 0)
        {
            treeView.SelectedNode = treeView.Nodes[0];
        }

    };

}).Bind(Model).GetHtml()

@*
@Html.DevExpress().Label(settings =>
{
    settings.Name = "nodeNamecccc";
    settings.Text = ViewData["SelectNodeName"].ToString();
    settings.ClientVisible = false;
}).GetHtml()*@
    <!--树形节点焦点值 -->


    @Html.Hidden("hdFocusNodeName", ViewData["focusNodeName"])
    @*@Html.Hidden("hdActionOP", ViewData["actionOP"])*@
</body>
</html>
